﻿package frEngine.animateControler.particleControler.animate
{
    import __AS3__.vec.*;
    import flash.geom.*;
    import frEngine.animateControler.particleControler.*;

    public class UseUvStep extends Object implements IParticleAnimate
    {
        private var _uNum:int;
        private var _vNum:int;
        private var maxOffset:int;
        private var speed:Number;
        public static const instance:UseUvStep = new UseUvStep;

        public function UseUvStep()
        {
            return;
        }// end function

        public function get objClass() : Class
        {
            return UseUvStep;
        }// end function

        public function canOpen(param1:ParticleParams) : Boolean
        {
            return param1.uvStep != null && param1.uvFingerConst == null;
        }// end function

        public function update(param1:ParticleStatus) : void
        {
            var _loc_4:ParticleItem = null;
            var _loc_5:Vector3D = null;
            var _loc_7:int = 0;
            var _loc_2:* = param1.particleList;
            var _loc_3:* = _loc_2.length;
            var _loc_6:int = 0;
            while (_loc_6 < _loc_3)
            {
                
                _loc_4 = _loc_2[_loc_6];
                if (_loc_4.visible && _loc_4.toUpdate)
                {
                    _loc_7 = _loc_4.curFrame * this.speed + int(_loc_4.randomValue * this.maxOffset);
                    _loc_4.uOffset = _loc_4.uOffset + _loc_7 % this._uNum / this._uNum;
                    _loc_4.vOffset = _loc_4.vOffset + int(_loc_7 / this._uNum) % this._vNum / this._vNum;
                }
                _loc_6++;
            }
            return;
        }// end function

        public function init(param1:ParticleStatus, param2:ParticleParams) : void
        {
            param1.openUvOffset = true;
            var _loc_3:* = param2.uvStep;
            this._uNum = _loc_3.x;
            this._vNum = _loc_3.y;
            this.maxOffset = _loc_3.w;
            this.speed = isNaN(_loc_3.z) ? (1) : (1 / _loc_3.z);
            return;
        }// end function

    }
}
